﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using XLua;
[LuaCallCSharp]
public class ImageLua
{
    private static Image m_transform;

    public static void On(uint skinID)
    {
        GameObject go = ObjectManager.Instance.GetGameObject(skinID);
        if (go != null)
        {
            m_transform = go.GetComponent<Image>();
        }

    }

    public static void Off()
    {
        m_transform = null;
    }

    public static void SetSprite(uint skinID, uint assetID, string spriteName)
    {
        On(skinID);
        SetSprite(assetID, spriteName);
    }

    public static void SetSprite(uint assetID, string spriteName)
    {
        if (m_transform == null) return;
        Sprite sp = LoadManager.Instance.GetSpriteByResIDAndName(assetID, spriteName);
        if(sp == null)
        {
            Debug.LogError("assetID：" + assetID + "没有找到spriteName：" + spriteName + "的UI");
        }
        else
        {
            m_transform.sprite = sp;
        }
    }
}

